package tech.wetech.admin.modules.system.web;

import com.github.pagehelper.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import tech.wetech.admin.core.utils.Result;
import tech.wetech.admin.modules.base.query.PageQuery;
import tech.wetech.admin.modules.base.web.BaseCrudController;
import tech.wetech.admin.modules.system.po.BusHeart;
import tech.wetech.admin.modules.system.po.SelectTime;
import tech.wetech.admin.modules.system.service.BusHeartService;

import java.util.List;

/**
 * @author lu
 * @description 心跳管理
 * @date 2019年06月12日 9:13
 */
@Controller
@RequestMapping("/busheart")
@Api(value = "心跳管理信息查询", description = "心跳管理基本信息操作API")
public class BusHeartController extends BaseCrudController<BusHeart> {

    @Autowired
    private BusHeartService heartService;

    @GetMapping
    public String userPage(Model model) {
        return "system/busheart";
    }
    /*
    ** @author lu
    * @date 2019/6/13 13:50
    * @param [busHeart, pageQuery]
    * @return tech.wetech.admin.core.utils.Result
    * @description 分页查询数据
    */
    @GetMapping("/selectlist")
    @ApiOperation("公交分页查询数据")
    @ResponseBody
    public Result queryList(BusHeart busHeart, PageQuery pageQuery, SelectTime selectTime) {
        List<BusHeart> list = heartService.querySelectList(busHeart, pageQuery,selectTime);
        return Result.success(list)
                .addExtraIfTrue(pageQuery.isCountSql(), "total", ((Page) list).getTotal());
    }
}
